import axios from "../utils/axios"
//表格渲染
// const examinationApi = async (page: Number, limit: Number, name: string,provinceId:number,cityId:number,subOrganId:number) => {
const examinationApi = async (page: Number, limit: Number, name: string,provinceId:number,cityId:number,organId:number) => {
    const data = await axios({
        url: '/item/list',
        method: 'post',
        data: {
            page: page,
            limit: limit,
            name: name,
            provinceId:provinceId,
            cityId:cityId,
            organId:organId
        }
    })
    return data;

}
//添加接口
const addExamination = async (_data: {
    attention: string,
    currentPrice: number,
    examinationMeaning: string,
    examinationScope: string,
    id: number,
    itemOrgans: number[],
    name: string,
    orderNumber: number,
    originalPrice: number,
    status: number,
    tags: number[]
}) => {
    const data = await axios({
        url: 'item/add',
        method: 'post',
        data: _data
    })
    return data;

}
//编辑接口
const editExamination = async (_data:
    {
        attention: string,
        currentPrice: number,
        examinationMeaning: string,
        examinationScope: string,
        id: null,
        itemOrgans: number[],
        name: string,
        orderNumber: number,
        originalPrice: number,
        status: number,
        tags: number[],
        tagIds:number,
        subName:string,
        provinceName:string,
        cityName:string,
        organName:string
    }) => {
    const data = await axios({
        url: '/item/update',
        method: 'post',
        data: _data
    })
    return data;
}
const editDataid = async (id: number) => {
    const data = await axios({
        url: '/item/' + id + '',
    })
    return data
}
//删除
const deleteId = async (id: number) => {
    const data = await axios({
        url: 'item/deleteById?id=' + id + ''
    })
    return data;
}

//分支机构
const organData = async (organId: number, cityId: string, provinceId: number) => {
    const data = await axios({
        url: '/examinationOrgan/addSubOrgan',
        method: 'post',
        data: {
            organId: organId,

        }
    })
    return data
}
//批量删除
const deleteAll = async (ids: number[]) => {
    const data = await axios({
        url: '/item/deleteByIds',
        method: 'post',
        data: {
            ids: ids
        }
    })
    return data;
}
export {
    examinationApi,
    addExamination,
    editExamination,
    editDataid,
    deleteId,
    deleteAll,
    organData
}